package com.lwc.cfdns.pojo.bo.system;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lwc.cfdns.pojo.bo.AbstractPageQuery;
import com.lwc.cfdns.pojo.entity.SystemConfig;
import com.lwc.cfdns.pojo.entity.SystemDict;
import com.lwc.cfdns.utils.StringUtils;
import lombok.Data;

/**
 * 列表查询条件
 *
 * @author luwc
 * @title ConfigBO
 * @description
 * @time 2023/6/1 09:50:12
 * @version: 1.0
 */
@Data
public class ConfigBO extends AbstractPageQuery<SystemConfig> {
    private Long cateId;
    private String name;
    private String enName;
    private String keyType;
    private String type;

    /**
     * 生成query conditions
     *
     * @return LambdaQueryWrapper<T>
     * @throws
     * @version 1.0.0
     * @author luwc
     * @time 2023/4/26 20:17:17
     */
    @Override
    public LambdaQueryWrapper<SystemConfig> toQueryWrapper() {
        LambdaQueryWrapper<SystemConfig> lambdaQueryWrapper = new LambdaQueryWrapper<>();

        if (StringUtils.isNotNull(getCateId())) {
            lambdaQueryWrapper.eq(SystemConfig::getCateId, getCateId());
        }
        if (StringUtils.isNotEmpty(getName())) {
            lambdaQueryWrapper.like(SystemConfig::getName, getName());
        }
        if (StringUtils.isNotEmpty(getEnName())) {
            lambdaQueryWrapper.like(SystemConfig::getEnName, getEnName());
        }
        if (StringUtils.isNotEmpty(getKeyType())) {
            lambdaQueryWrapper.eq(SystemConfig::getKeyType, getKeyType());
        }
        if (StringUtils.isNotEmpty(getType())) {
            lambdaQueryWrapper.eq(SystemConfig::getType, getType());
        }

        return lambdaQueryWrapper;
    }
}
